package com.sise.model;

import java.io.Serializable;
import java.util.Objects;
import java.util.TreeSet;

/**
 * 字符节点
 *
 * @author idea
 * @data 2019/5/27
 */
public class StringWordNode implements Serializable {

    /**
     * 头两个字符的hash值
     */
    public int headCharHash;

    public TreeSet<StringItem> treeSet=new TreeSet<>();

    public StringWordNode next;

    public StringWordNode(int headCharMix) {
        this.headCharHash = headCharMix;
    }

    public StringWordNode(int headCharMix, StringWordNode parent) {
        this.headCharHash = headCharMix;
        parent.next = this.next;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        StringWordNode that = (StringWordNode) o;
        return headCharHash == that.headCharHash &&
                Objects.equals(treeSet, that.treeSet) &&
                Objects.equals(next, that.next);
    }

    @Override
    public int hashCode() {

        return Objects.hash(headCharHash, treeSet, next);
    }
}
